Skip to content

Add --ignore-video-encoder-constraints#6849

Closed
rom1v wants to merge 2 commits into
devfrom
ignore-video-encoder-constraints
Closed

Add --ignore-video-encoder-constraints#6849
rom1v wants to merge 2 commits into
devfrom
ignore-video-encoder-constraints

Conversation

@rom1v

@rom1v rom1v commented May 18, 2026

Copy link
Copy Markdown
Collaborator

Some encoders report incorrect capabilities. Add an option to ignore these constraints.

Fixes #6829
Fixes #6848

rom1v added 2 commits May 18, 2026 23:34
Some encoders report incorrect capabilities. Add an option to ignore
these constraints.

Fixes #6829 <#6829>
Fixes #6848 <#6848>
@rom1v

rom1v commented May 20, 2026

Copy link
Copy Markdown
Collaborator Author

When --ignore-video-encoder-constraints is set, maybe I should change the default value for --min-size-alignment to 8 if it is not explicitly set, otherwise the video will often fail due to misalignment… Or maybe not…

@anotheruserofgithub

Copy link
Copy Markdown

Or maybe this option should only apply to max/min size, not alignment?

I guess the alignment reported by video capabilities will always work (except e.g. for emulators).

But I'm even wondering if the supported size is really wrong. In #6769 (comment) as well as in other issues you're assuming that the encoder reports incorrect capabilities. It seems more probable that the way you compute the maximum possible size is not appropriate, as additional logs in #6769 (comment) tend to suggest (IMHO).

What I mean is that I wouldn't be surprised if the encoder could handle only a limited number of pixels in total or a limited aspect ratio, something like that. Thus if you first retrieve the maximum allowed width and the encoder returns 2048, then if you ask it the maximum possible height it can handle for this width it will return 448. On the other hand, if you ask what is the maximum height for a width of, say, 1600, it would return 1200 or higher. In other words, maybe it can handle larger areas for big squares than for thin rectangles, but anyway the more you increase one dimension, the more the other dimension has to be limited. Or maybe not? How would you know a priori? You should probably test with more values on a real device.

As a consequence, the decision for the maximum minor dimension should depend dynamically on the current (capped) major dimension in Size.constrain().

I don't know, just a guess. At least, did I manage to make myself clear?

@rom1v

rom1v commented May 22, 2026

Copy link
Copy Markdown
Collaborator Author

@anotheruserofgithub Thank you, you're right! I completely reworked the size constraint algorithm: #6859 (which replaces this PR, so I'm closing).

@rom1v rom1v closed this May 22, 2026
rom1v added a commit that referenced this pull request May 23, 2026
The algorithm used to constrain a size according to the video
capabilities, implemented in #6766, was too simplistic: it computed the
maximum landscape size by retrieving the maximum width and its
associated maximum height (and vice versa for the maximum portrait
size).

In addition to width and height, encoders are also constrained by a
maximum surface area (in blocks). As a result, it is possible for the
maximum width to be 4096 with an associated maximum height of 512, while
the encoder still supports 1600x1200.

In that case, the previous algorithm incorrectly considered 512 to be
the absolute maximum height in landscape mode.

Instead, determine the optimal supported size, defined as the largest
size with the same aspect ratio supported by the encoder. If preserving
the aspect ratio is not required (for virtual displays), then the second
dimension derived from this optimal size can be extended.

Refs #6849 comment <#6849 (comment)>
Refs #6766 <#6766>
Refs #6848 <#6848>
Fixes #6829 <#6829>
PR TODO
rom1v added a commit that referenced this pull request May 23, 2026
Add an option to ignore video encoder constraints.

Refs #6829 <#6829>
Refs #6849 <#6849>
Fixes #6848 <#6848>
PR TODO
rom1v added a commit that referenced this pull request May 23, 2026
Add an option to ignore video encoder constraints.

Refs #6829 <#6829>
Refs #6849 <#6849>
Fixes #6848 <#6848>
PR TODO
rom1v added a commit that referenced this pull request May 24, 2026
The algorithm used to constrain a size according to the video
capabilities, implemented in #6766, was too simplistic: it computed the
maximum landscape size by retrieving the maximum width and its
associated maximum height (and vice versa for the maximum portrait
size).

In addition to width and height, encoders are also constrained by a
maximum surface area (in blocks). As a result, it is possible for the
maximum width to be 4096 with an associated maximum height of 512, while
the encoder still supports 1600x1200.

In that case, the previous algorithm incorrectly considered 512 to be
the absolute maximum height in landscape mode.

Instead, determine the optimal supported size, defined as the largest
size with the same aspect ratio supported by the encoder. If preserving
the aspect ratio is not required (for virtual displays), then the second
dimension derived from this optimal size can be extended.

Refs #6849 comment <#6849 (comment)>
Refs #6766 <#6766>
Refs #6848 <#6848>
Fixes #6829 <#6829>
PR TODO
rom1v added a commit that referenced this pull request May 24, 2026
Add an option to ignore video encoder constraints.

Refs #6829 <#6829>
Refs #6849 <#6849>
Fixes #6848 <#6848>
PR TODO
rom1v added a commit that referenced this pull request May 24, 2026
The algorithm used to constrain a size according to the video
capabilities, implemented in #6766, was too simplistic: it computed the
maximum landscape size by retrieving the maximum width and its
associated maximum height (and vice versa for the maximum portrait
size).

In addition to width and height, encoders are also constrained by a
maximum surface area (in blocks). As a result, it is possible for the
maximum width to be 4096 with an associated maximum height of 512, while
the encoder still supports 1600x1200.

In that case, the previous algorithm incorrectly considered 512 to be
the absolute maximum height in landscape mode.

Instead, determine the optimal supported size, defined as the largest
size with the same aspect ratio supported by the encoder. If preserving
the aspect ratio is not required (for virtual displays), then the
dimensions derived from this optimal size can be extended.

Refs #6849 comment <#6849 (comment)>
Refs #6766 <#6766>
Refs #6848 <#6848>
Fixes #6829 <#6829>
PR TODO
rom1v added a commit that referenced this pull request May 24, 2026
Add an option to ignore video encoder constraints.

Refs #6829 <#6829>
Refs #6849 <#6849>
Fixes #6848 <#6848>
PR TODO
rom1v added a commit that referenced this pull request May 25, 2026
The algorithm used to constrain a size according to the video
capabilities, implemented in #6766, was too simplistic: it computed the
maximum landscape size by retrieving the maximum width and its
associated maximum height (and vice versa for the maximum portrait
size).

In addition to width and height, encoders are also constrained by a
maximum surface area (in blocks). As a result, it is possible for the
maximum width to be 4096 with an associated maximum height of 512, while
the encoder still supports 1600x1200.

In that case, the previous algorithm incorrectly considered 512 to be
the absolute maximum height in landscape mode.

Instead, determine the optimal supported size, defined as the largest
size with the same aspect ratio supported by the encoder. If preserving
the aspect ratio is not required (for virtual displays), then the
dimensions derived from this optimal size can be extended.

Refs #6849 comment <#6849 (comment)>
Refs #6766 <#6766>
Refs #6848 <#6848>
Fixes #6829 <#6829>
PR #6859 <#6859>
rom1v added a commit that referenced this pull request May 27, 2026
The algorithm used to constrain a size according to the video
capabilities, implemented in #6766, was too simplistic: it computed the
maximum landscape size by retrieving the maximum width and its
associated maximum height (and vice versa for the maximum portrait
size).

In addition to width and height, encoders are also constrained by a
maximum surface area (in blocks). As a result, it is possible for the
maximum width to be 4096 with an associated maximum height of 512, while
the encoder still supports 1600x1200.

In that case, the previous algorithm incorrectly considered 512 to be
the absolute maximum height in landscape mode.

Instead, determine the optimal supported size, defined as the largest
size with the same aspect ratio supported by the encoder. If preserving
the aspect ratio is not required (for virtual displays), then the
dimensions derived from this optimal size can be extended.

Refs #6849 comment <#6849 (comment)>
Refs #6766 <#6766>
Refs #6848 <#6848>
Fixes #6829 <#6829>
PR #6859 <#6859>
rom1v added a commit that referenced this pull request May 27, 2026
The algorithm used to constrain a size according to the video
capabilities, implemented in #6766, was too simplistic: it computed the
maximum landscape size by retrieving the maximum width and its
associated maximum height (and vice versa for the maximum portrait
size).

In addition to width and height, encoders are also constrained by a
maximum surface area (in blocks). As a result, it is possible for the
maximum width to be 4096 with an associated maximum height of 512, while
the encoder still supports 1600x1200.

In that case, the previous algorithm incorrectly considered 512 to be
the absolute maximum height in landscape mode.

Instead, determine the optimal supported size, defined as the largest
size with the same aspect ratio supported by the encoder. If preserving
the aspect ratio is not required (for virtual displays), then the
dimensions derived from this optimal size can be extended.

Refs #6849 comment <#6849 (comment)>
Refs #6766 <#6766>
Refs #6848 <#6848>
Fixes #6829 <#6829>
PR #6859 <#6859>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants